﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Gift.DAL;
using Gift.Model;
using Gift.WebApp;
using System.Text;
using System.Data;
using System.Xml;

public partial class cn_channel : BasePage
{

 
    tbCompany oCompany;

    protected string xmlPath = "/cn/xml/channel.xml";

    // Methods
    protected StringBuilder CategoryBind()
    {
        StringBuilder builder = new StringBuilder();
        try
        {
            if (base.Request.QueryString["company"] == null)
            {
                return builder;
            }
            builder.AppendLine("<div class=\"container chanelmenu\">");
            oCompany = BaseFactory.theCompany.GetModel(int.Parse(base.Request.QueryString["company"]));
            if (oCompany != null)
            {
                builder.AppendLine("<h3> <strong>" + oCompany.Name + "</strong> </h3>");
                DataTable table2 = BaseFactory.theCategory.GetCategoryByNavigationTypeAndIsShow(0, 1, int.Parse(base.Request.QueryString["company"])); 
                builder.AppendLine("<span>");
                int num = 0;
                foreach (DataRow row in table2.Rows)
                {
                    if (num < 8)
                    {
                        builder.AppendLine(string.Concat(new object[] { "<a href=\"goods_list.html?cid=", row["categoryIdentity"], "\">", row["categoryName"], "</a>" }));
                        num++;
                    }
                }
                builder.AppendLine("<a href=\"goods_list.html?company=" + oCompany.Id + "\">全部分类</a></span>");
            }
            builder.AppendLine("</div>");
        }
        catch
        {
        }
        return builder;
    }

    protected string DescriptionBind()
    {
        string str = "";
        try
        {
            if (base.Request.QueryString["company"] == null)
            {
                return str;
            }
            oCompany = BaseFactory.theCompany.GetModel(int.Parse(base.Request.QueryString["company"]));
            if(oCompany != null)
            {
                return oCompany.Name;
            }
        }
        catch
        {
        }
        return str;
    }

    protected string KeywordsBind()
    {
        string str = "";
        try
        {
            //if (base.Request.QueryString["cid"] == null)
            //{
            //    return str;
            //}
            //DataTable categoryById = this.theCategory.GetCategoryById(base.Request.QueryString["cid"]);
            //if (categoryById.Rows.Count > 0)
            //{
            //    str = categoryById.Rows[0]["keywords"].ToString();
            //}
            //if (str != "")
            //{
            //    str = str + "，";
            //}
        }
        catch
        {
        }
        return str;
    }

    protected void Page_Load(object sender, EventArgs e)
    {
    }

    protected StringBuilder SlidesAdBind()
    {
        StringBuilder builder = new StringBuilder();
        try
        {
            DataRow row;
            DataTable categoryAdByCategory = BaseFactory.theCategoryAd.GetCategoryAdByCategory(base.Request.QueryString["cid"]);
            builder.AppendLine("<div class=\"container\">");
            builder.AppendLine("<div class=\"ad\">");
            builder.AppendLine("<ul class=\"slider\">");
            if (categoryAdByCategory.Rows.Count > 0)
            {
                row = categoryAdByCategory.Rows[0];
                builder.AppendLine(string.Concat(new object[] { "<li><a href=\"", row["slidesOneUrl"], "\" target=\"_blank\"><img src=\"", row["slidesOne"], "\" alt=\"", row["slidesOneAlt"], "\" /></a></li>" }));
                builder.AppendLine(string.Concat(new object[] { "<li><a href=\"", row["slidesTwoUrl"], "\" target=\"_blank\"><img src=\"", row["slidesTwo"], "\" alt=\"", row["slidesTwoAlt"], "\" /></a></li>" }));
            }
            else
            {
                builder.AppendLine("<li><a href=\"#\" target=\"_blank\"><img src=\"/cn/category_ad/ChannelSlides1.jpg\" alt=\"\" /></a></li>");
                builder.AppendLine("<li><a href=\"#\" target=\"_blank\"><img src=\"/cn/category_ad/ChannelSlides2.jpg\" alt=\"\" /></a></li>");
            }
            builder.AppendLine("</ul>");
            builder.AppendLine("<ul class=\"num\">");
            builder.AppendLine("<li>1</li>");
            builder.AppendLine("<li>2</li>");
            builder.AppendLine("</ul>");
            builder.AppendLine("</div>");
            if (categoryAdByCategory.Rows.Count > 0)
            {
                row = categoryAdByCategory.Rows[0];
                builder.AppendLine(string.Concat(new object[] { "<a href=\"", row["slidesLeftUrl"], "\" target=\"_blank\"><img class=\"float\" src=\"", row["slidesLeft"], "\" alt=\"", row["slidesLeftAlt"], "\" /></a>" }));
            }
            else
            {
                builder.AppendLine("<a href=\"#\" target=\"_blank\"><img class=\"float\" src=\"/cn/category_ad/ChannelSlidesLeft.jpg\" alt=\"\" /></a>");
            }
            builder.AppendLine("<span class=\"clear\"></span>");
            builder.AppendLine("</div>");
        }
        catch
        {
        }
        return builder;
    }

}